package drinkreos;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.MouseListener;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import drinkreos.model.Card;

public class CardView extends JPanel {
	private JLabel titleLabel;
	private JLabel textLabel;
	private JLabel characterLabel;
	private static final Dimension cardDimension=new Dimension(371,600);
	private static final Font titleFont=new Font("Arial", Font.PLAIN, 50);
	private static final Font textFont=new Font("Arial", Font.PLAIN, 30);
	private static final Font characterFont=new Font("Arial", Font.PLAIN, 40);

	public CardView() {
		super(new BorderLayout());
		setBorder(BorderFactory.createLineBorder(Color.black));
		titleLabel=new JLabel();
			this.add(titleLabel,BorderLayout.BEFORE_FIRST_LINE);
			titleLabel.setFont(titleFont);
			titleLabel.setHorizontalAlignment( SwingConstants.CENTER );
		textLabel=new JLabel();
			add(textLabel,BorderLayout.CENTER);
			textLabel.setFont(textFont);
		characterLabel=new JLabel();
			add(characterLabel,BorderLayout.AFTER_LAST_LINE);
			characterLabel.setFont(characterFont);
			characterLabel.setHorizontalAlignment( SwingConstants.CENTER );
	}
	
	@Override
	public Dimension getPreferredSize() {
		return cardDimension;
	}
	
	public void setCard(Card c) {
		if(c==null) {
			titleLabel.setText(null);
			textLabel.setText(null);
			characterLabel.setText(null);
		}
		else {
			titleLabel.setText("<html><p>"+c.getName()+"</html></p>");
			textLabel.setText("<html><p>"+c.getText()+"</html></p>");
			characterLabel.setText("<html><p>"+c.getCharacter()+" "+c.getTurnsInPlay()+"</html></p>");
		}
	}
}
